filechooser: follow the gtk-recent-files-enabled GtkSetting
authorCosimo Cecchi <cosimoc@gnome.org>
Wed, 13 Feb 2013 16:39:53 +0000 (11:39 -0500)
committerCosimo Cecchi <cosimoc@gnome.org>
Wed, 13 Feb 2013 17:06:43 +0000 (12:06 -0500)
Avoid showing the Recent files entry if the setting is FALSE.

https://bugzilla.gnome.org/show_bug.cgi?id=693709

gtk/gtkfilechooserdefault.c
gtk/gtkfilechooserprivate.h

index 3eff2206a73260b842160b6913e01173452da5bd..3f900986f16d5f440bc3f6dcedc3b0ddcd903479 100644 (file)
@@ -1736,11 +1736,31 @@ shortcuts_append_search (GtkFileChooserDefault *impl)
   impl->has_search = TRUE;
 }
 
+static gboolean
+shortcuts_get_recent_enabled (GtkWidget *widget)
+{
+  GtkSettings *settings;
+  gboolean enabled;
+
+  if (gtk_widget_has_screen (widget))
+    settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
+  else
+    settings = gtk_settings_get_default ();
+
+  g_object_get (settings, "gtk-recent-files-enabled", &enabled, NULL);
+  return enabled;
+}
+
 static void
 shortcuts_append_recent (GtkFileChooserDefault *impl)
 {
   GdkPixbuf *pixbuf;
   GtkTreeIter iter;
+  gboolean enabled;
+
+  enabled = shortcuts_get_recent_enabled (GTK_WIDGET (impl));
+  if (!enabled)
+    return;
 
   pixbuf = render_recent_icon (impl);
 
@@ -1756,6 +1776,8 @@ shortcuts_append_recent (GtkFileChooserDefault *impl)
   
   if (pixbuf)
     g_object_unref (pixbuf);
+
+  impl->has_recent = TRUE;
 }
 
 /* Appends an item for the user's home directory to the shortcuts model */
@@ -1871,7 +1893,7 @@ shortcuts_get_index (GtkFileChooserDefault *impl,
   if (where == SHORTCUTS_RECENT)
     goto out;
 
-  n += 1; /* we always have the recently-used item */
+  n += impl->has_recent ? 1 : 0;
 
   if (where == SHORTCUTS_RECENT_SEPARATOR)
     goto out;
index 907c9df2366de9aa3c7071f45b9d3c5b6d0b8e95..2a74e39f7ef9ce0664f1e4df7f42e8203f8d49dd 100644 (file)
@@ -308,6 +308,7 @@ struct _GtkFileChooserDefault
   guint has_home : 1;
   guint has_desktop : 1;
   guint has_search : 1;
+  guint has_recent: 1;
   guint show_size_column : 1;
   guint create_folders : 1;